<template>
	<view style="padding: 30rpx;">
		<button @click="onsetTimeCall()">单次定时器setTimeout</button>
		<button @click="onsetTimeCallxy()">带参数setTimeout</button>
		<button @click="onTimeoutClear()"type="warn">取消定时器</button>
		<button @click="onInteral()"type="primary">周期打印</button>
		<button @click="onClearInter()"type="primary" plain="true">取消周期打印</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'zss',
				password:'666',
				timeoutID:null,
				count:0
			}
		},
		methods: {
			onsetTimeCall(){
				console.log("onsetTimeCall-->");
				// setTimeout(callback,ms,ayn[])
				// 箭头函数（匿名函数）（）=>{}
				setTimeout(()=>{
					// 延时之后要执行的代码
					console.log("我延时2秒才会打印");
				},2000)
			},
			onsetTimeCallxy(name,pwd){
				console.log("onsetTimeCallxy--> name:"+name+",pwd"+pwd);
				//
				setTimeout((x,y)=>{
					console.log("我可以传参数了> x:"+x+",y"+y);
				},2000,name,pwd)
				
			},
			onTimeoutClear(){
				console.log("onTimeoutClear------>定时器被我取消了："+this.timeoutID);
				clearTimeout(this.timeoutID);
			},
			onInteral(){
				setInteral(()=>{
					this.count++;
					console.log("周期打印 count:",this.count);
				},1000)
			},
			onClearInter(){
				console.log("onClearInter:"+this.InterID);
				clearInter(this.InterID);
			}
		}
	}
</script>

<style>

</style>
